package com.bwf.redirect;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @Version v1.0
 * @Description: TODO
 * @Author ZHANZHONGXIN
 * @Date 2022/6/8 15:58
 * @Copyright 博为峰
 */
public class ServletDemo02 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("ServletDemo02");
        //------响应---------------------------------
        resp.setHeader("r02","r02");
        PrintWriter printWriter = resp.getWriter();
        printWriter.write("<h1>r02</h1>");
        //------获取数据---------------------------------
        Object servletName = req.getAttribute("servletName");
        System.out.println("servletName = " + servletName);
    }
}
